!include "MUI2.nsh"

Name "Python EasyAccept"
OutFile "PythonEasyAccept.exe"

InstallDir $PROGRAMFILES\PythonEasyAccept

InstallDirRegKey HKLM "Software\PythonEasyAccept" "Install_Dir"

BrandingText " "

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
 
!insertmacro MUI_LANGUAGE "English"

Function .onInit
        InitPluginsDir
        File /oname=$PLUGINSDIR\logo.bmp "icons\PEA.bmp"
        advsplash::show 5000 600 400 -1 $PLUGINSDIR\logo
	Pop $0
FunctionEnd

Section "wxPython 2.8"
    CreateDirectory $INSTDIR\Prerequisites
    SetOutPath $INSTDIR\Prerequisites
    File "wxPython2.8-win32-unicode-2.8.8.0-py25.exe"
    ExecWait '"$INSTDIR\Prerequisites\wxPython2.8-win32-unicode-2.8.8.0-py25.exe"'
SectionEnd

Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\PythonEasyAccept"
  CreateShortCut "$SMPROGRAMS\PythonEasyAccept\PythonEasyAccept! - Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\PythonEasyAccept\PythonEasyAccept!.lnk" "$INSTDIR\PythonEasyAccept.py" "" "$INSTDIR\PythonEasyAccept.py" 0  
SectionEnd

Section "PythonEasyAccept"

  SectionIn RO
  
  SetOutPath $INSTDIR
   

    File "setup.py"
    File "src\pyeasyaccept\PythonEasyAccept.py"

    CreateDirectory $PROGRAMFILES\PythonEasyAccept\icons
    SetOutPath $INSTDIR\icons

    File "icons\IconPEA.bmp"
    File "icons\my_run.png"
    File "icons\PEA.bmp"
    File "icons\removeButton.png"
    File "icons\run.png"
    File "icons\IconPEA.ico"

    SetOutPath $INSTDIR

    File /r /x ".svn" "src"

    nsExec::ExecToLog 'python setup.py install'
  
    WriteRegStr HKLM SOFTWARE\PythonEasyAccept "Install_Dir" "$INSTDIR"
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PythonEasyAccept" "DisplayName" "PythonEasyAccept"
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PythonEasyAccept" "UninstallString" '"$INSTDIR\uninstall.exe"'
    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PythonEasyAccept" "NoModify" 1
    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PythonEasyAccept" "NoRepair" 1
    WriteUninstaller "uninstall.exe"
  
SectionEnd



Section "Uninstall"
  
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PythonEasyAccept"
  DeleteRegKey HKLM SOFTWARE\PythonEasyAccept

  Delete /REBOOTOK "$INSTDIR\uninstall.exe"
  Delete /REBOOTOK "$INSTDIR\PythonEasyAccept.py"
  Delete /REBOOTOK "$SMPROGRAMS\PythonEasyAccept\*.*"

  ; Remove directories used
  RMDir /r /REBOOTOK "$SMPROGRAMS\PythonEasyAccept"
  RMDir /r /REBOOTOK "$INSTDIR"

SectionEnd